package org.budo.support.dao.page;

import java.io.Serializable;
import java.util.List;

/**
 * 作为分页查询时的返回结果
 * 
 * @author lmw
 * @see org.budo.support.dao.page.Page
 */
public class PageModel<T> implements Serializable {
    private static final long serialVersionUID = 3015209047580315558L;

    private Integer recordCount;

    private List<T> list;

    public PageModel() {}

    public PageModel(List<T> list, Integer recordCount) {
        this.setList(list);
        this.setRecordCount(recordCount);
    }

    public PageModel(List<T> list, Page page) {
        this.setList(list);

        Integer recordCount = null == page ? null : page.getRecordCount();
        this.setRecordCount(recordCount);
    }

    public Integer getRecordCount() {
        return this.recordCount;
    }

    public void setRecordCount(Integer recordCount) {
        this.recordCount = recordCount;
    }

    public List<T> getList() {
        return this.list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public boolean isEmpty() {
        return null == this.getList() || this.getList().isEmpty();
    }

    public String toString() {
        return super.toString() + ", recordCount=" + this.getRecordCount() + ", list=" + this.getList();
    }
}